use core::ops::Deref;

use stm32f4::stm32f407;
use stm32f4::stm32f407::{uart4, uart5, uart7, uart8, usart1, usart2, usart3, usart6};

pub struct UART1;
pub struct UART2;
pub struct UART3;
pub struct UART4;
pub struct UART5;
pub struct UART6;
pub struct UART7;
pub struct UART8;

impl Deref for UART1 {
    type Target = usart1::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::USART1::PTR }
    }
}

impl Deref for UART2 {
    type Target = usart2::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::USART2::PTR }
    }
}

impl Deref for UART3 {
    type Target = usart3::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::USART3::PTR }
    }
}

impl Deref for UART4 {
    type Target = uart4::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::UART4::PTR }
    }
}

impl Deref for UART5 {
    type Target = uart5::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::UART5::PTR }
    }
}

impl Deref for UART6 {
    type Target = usart6::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::USART6::PTR }
    }
}

impl Deref for UART7 {
    type Target = uart7::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::UART7::PTR }
    }
}

impl Deref for UART8 {
    type Target = uart8::RegisterBlock;
    fn deref(&self) -> &Self::Target {
        unsafe { &*stm32f407::UART8::PTR }
    }
}
